package controller;

import java.io.FileInputStream;
import java.io.InputStream;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.util.Properties;

import logica.IFachada;

public class RemoteFachada {
	
	private static RemoteFachada instancia;
	
	private IFachada fachada;
	
	private RemoteFachada() throws RemoteException
	{ 
		try{
			Properties p = new Properties();
		    InputStream is = new FileInputStream("configuraciones.properties");
		    p.load(is);
		    is.close();
	
		    String port = p.getProperty("port");
		    String host = p.getProperty("ipServidor");
		    		    
			this.fachada = (IFachada) Naming.lookup("//" + host + ":" + port + "/fachada");
			
		}
		catch (Exception e){
			throw new RemoteException();
		}
		
	}
	
	public static RemoteFachada getInstancia() throws RemoteException
	{
		if (instancia == null)
			instancia = new RemoteFachada();
		return instancia;
	}
	
	public IFachada getFachada(){
		return this.fachada;
	}

}
